package com.fenghuo.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TimeUtil {
	private static SimpleDateFormat format;

	
	/**得到时间str yy-MM-dd HH:mm
	 * @return
	 */
	public static String gettimestr() {
		format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		return format.format(new Date());
	}
	
	/**得到日期str yy-MM-dd
	 * @return
	 */
	public static String getdatestr(){
		format=new SimpleDateFormat("yyyy-MM-dd");
		return format.format(new Date());
	}
	
	/**得到当前日期 加、减 reduceday 后的日期
	 * @param reduceday
	 * @return
	 */
	public static String getday(int reduceday){
		format=new SimpleDateFormat("yyyy-MM-dd");
		Calendar calendar=Calendar.getInstance();
		Date now=new Date();
		calendar.set(now.getYear()+1900, now.getMonth(), now.getDate());
		calendar.add(Calendar.DATE, reduceday);
		Date date = calendar.getTime();
		return format.format(date);
	}
	
}
